<? 
	include('base.php');
	User::protect();
	include_class('venues');
	include_class('locations');
	include_class('band_information');
	$page_title = 'View/Edit Venues';
	$section = 'venues';
	$javascript = 'venues.js';
	include('layout/header.php');
	
	$bi = BandInformation::get();
	$defaultStateProvince = $bi->getDefaultStateProvince();
	$defaultCity = $bi->getDefaultCity();
	$defaultCountry = $bi->getDefaultCountry();
	
?>

<div id="breadcrumb">
	<a href="index.php">Audition &#62;</a>
	<a href="live.php">Live &#62;</a>
	Venues
</div>

	<h1>venues:</h1>
	<div class="inset">
	<?
		$sl = new VenueList();
		$limiter = array();
		$limiter['stateProvince'] = ($_REQUEST['stateProvince']) ? $_REQUEST['stateProvince'] : $defaultStateProvince;
		$limiter['city'] = ($_REQUEST['city']) ? $_REQUEST['city'] : $defaultCity;
		$venuelist = $sl->get($limiter);
		$splist = $sl->getStateProvinceList($defaultCountry);
		$limiter['city'] = null;
		$citylist = $sl->getCityList($limiter);
		
		$spl = new StateList();
		$ctl = new CountryList();
		$stateList = $spl->getStates();
		$countryList = $ctl->getCountries();
		$clist = $sl->getCountryList();
	?>
	
	<table border="0" cellspacing="1" cellpadding="0" class="edit-form">
	<tr>
		<td width="33%"><strong>Country</strong><br/>
			<select name="country" id="countries">
				<option value="">** Select Country</option>
			<? foreach ($clist as $ct => $total) { ?>
				<option value="<?=$ct?>"<? if ($_REQUEST['country'] == $ct || (!$_REQUEST['country'] && $ct == $defaultCountry)) { ?> selected<? } ?>><?=$countryList[$ct]?> (<?=$total?>)</option>
			<? } ?>
			</select>
			</td>
		<td width="34%"><strong>State/Province</strong><br/>
		<select name="stateProvince" id="stateProvince">
			<option value="">** Select State/Province</option>
		<? foreach ($splist as $sp => $total) {
			$item = ($stateList[$sp] == null) ? $sp : $stateList[$sp]; ?>
			<option value="<?=$sp?>"<? if ($_REQUEST['stateProvince'] == $sp || (!$_REQUEST['stateProvince'] && $sp == $defaultStateProvince)) { ?> selected<? } ?>><?=$item?> (<?=$total?>)</option>
		<? } ?>
		</select>
		</td>
		<td width="33%"><strong>City</strong><br/>
		<select name="city" id="city">
			<option value="">** Select City</option>
		<? foreach ($citylist as $ci => $total) { ?>
			<option value="<?=$ci?>"<? if ($_REQUEST['city'] == $ci || (!$_REQUEST['city'] && $ci == $defaultCity)) { ?> selected<? } ?>><?=$ci?> (<?=$total?>)</option>
		<? } ?>
		</select>
		</td>
	</tr>
	</table>
	<br/>
	<a href="venue_add.php">Add Venue</a><br/>
	<table border="0" cellspacing="1" cellpadding="0" class="list">
	<tr>
		<td class="header">Name</td>
	</tr>
	<tr>
		<td id="venueList"><? 
		if (is_array($venuelist) && count($venuelist) > 0) {
		foreach ($venuelist as $vn) { ?>
			<div class="venue"><a href="venue_edit.php?id=<?=$vn->getID()?>"><?=$vn->getName()?></a></div>
		<? }
		} else {?>
			No venues.
		<? } ?></td>
	</tr>
	</table>
	</div>


<? include('layout/footer.php'); ?>
